package com.lxt.controller;

import com.lxt.common.util.RedisOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;


@RestController
@ApiIgnore
@RequestMapping("redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedisOperator redisOperator;

    @GetMapping(value = "/set")
    public Object set(String key, String value) {
        //redisTemplate.opsForValue().set(key, value);
        redisOperator.set(key, value);
        return "ok";
    }

    @GetMapping(value = "/get")
    public Object get(String key) {
        //return (String) redisTemplate.opsForValue().get(key);
        return redisOperator.get(key);
    }

    @GetMapping(value = "/delete")
    public Object delete(String key) {
        //redisTemplate.delete(key);
        redisOperator.del(key);
        return "ok";
    }

}
